<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/5/4
  Time: 18:12
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>登录</title>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/js/jquery-easyui-1.5.4.5/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/js/jquery-easyui-1.5.4.5/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/js/jquery-easyui-1.5.4.5/demo/demo.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-easyui-1.5.4.5/jquery.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-easyui-1.5.4.5/jquery.easyui.min.js"></script>
</head>
<body>
    <div class="easyui-dialog" title="登录" style="width:400px;padding:30px 60px;" closable=false draggable=false>
        <form id="ff" method="post" action="${pageContext.request.contextPath}/user/loginSubmit">
            <div style="margin-bottom:20px">
                <input class="easyui-textbox" name="username" style="width:100%;" data-options="label:'账号：',required:true,missingMessage:'用户名不能为空！'">
            </div>
            <div style="margin-bottom:20px">
                <input class="easyui-passwordbox" name="password" iconWidth="28" style="width:100%;" data-options="label:'密码：',required:true,missingMessage:'密码不能为空！'">
            </div>
            <div style="text-align:center;padding:5px 0">
                <input type="submit" value="登录">
                <input type="button" value="重置" onclick="clearForm()">
            </div>
        </form>
    </div>
    <script>
        $(function(){
            $('#ff').form({
                success:function(data){
                    // var data = eval('(' + data + ')');  // change the JSON string to javascript object
                    if (data === 'null'){
                        $.messager.alert('提示', '用户名不存在', 'info');
                    } else if (data === 'error'){
                        $.messager.alert('提示', '密码错误', 'info');
                    } else {
                        location.href = data;
                    }
                }
            });
        });

        function clearForm(){
            $('#ff').form('clear');
        }
    </script>
</body>
</html>
